package com.yex.utils;

/**
 * @Author: 袁晓钧
 * @Date: Created in 2018/1/30 15:08
 * @Version: V1
 * @Description: resful api 统一结构
 */
public class JsonResultVo {

	private boolean success = true ;
	private String msg;
	private int code;
	private Object data;

	public JsonResultVo() {
		super();
	}

	public JsonResultVo(String msg) {
		super();
		this.msg = msg;
		this.code = 0;
	}

	public JsonResultVo(String msg, int code) {
		super();
		this.msg = msg;
		this.code = code;
	}

	public JsonResultVo(String msg, Object data, int code) {
		super();
		this.msg = msg;
		this.data = data;
		this.code = code;
	}

	public JsonResultVo(boolean success, String msg, int code) {
		super();
		this.success = success;
		this.msg = msg;
		this.code = code;
	}

	public JsonResultVo(boolean success, String msg, Object data, int code) {
		super();
		this.success = success;
		this.msg = msg;
		this.data = data;
		this.code = code;
	}

	public static JsonResultVo succ(String msg) {
		JsonResultVo jsonResultVo = new JsonResultVo();
		jsonResultVo.success = true;
		jsonResultVo.code = 0;
		jsonResultVo.msg = msg;
		return jsonResultVo;
	}

	public static JsonResultVo succ(String msg, Object data) {
		JsonResultVo jsonResultVo = new JsonResultVo();
		jsonResultVo.success = true;
		jsonResultVo.code = 0;
		jsonResultVo.msg = msg;
		jsonResultVo.data = data;
		return jsonResultVo;
	}

	public static JsonResultVo fail(int code, String msg) {
		JsonResultVo jsonResultVo = new JsonResultVo();
		jsonResultVo.success = false;
		jsonResultVo.code = code;
		jsonResultVo.msg = msg;
		return jsonResultVo;
	}

	public static JsonResultVo fail(int code, String msg, Object data) {
		JsonResultVo jsonResultVo = new JsonResultVo();
		jsonResultVo.success = false;
		jsonResultVo.code = code;
		jsonResultVo.msg = msg;
		jsonResultVo.data = data;
		return jsonResultVo;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
}
